<?php


namespace app\admin\system\controller;


use app\admin\system\logic\AttachmentLogic;
use app\common\controller\BaseAdminController;

/**
 * 附件管理
 * Class AttachmentController
 * @package app\admin\system\controller
 */
class AttachmentController extends BaseAdminController
{
    protected $noNeedRight = ['*'];

    protected function init()
    {
        parent::init();
        $this->logic = new AttachmentLogic();
    }


    protected function listOrder()
    {
        return ["id" => "desc"];
    }

    protected function searchWhere()
    {
        $where = [];
        $this->form['name'] && $where[] = ['name', 'like', "%{$this->form['name']}%"];
        $this->form['category_id'] && $where[] = ['category_id', '=', $this->form['category_id']];
        return $where;
    }

    public function listDictType()
    {
        $dictStatus = input('dictStatus');
        $where = [];
        if (!is_null($dictStatus)) {
            $where[] = ['dictStatus', '=', $dictStatus];
        }
        $data = $this->logic
            ->where($where)
            ->select();
        return $this->success($data);
    }

}